package com.elepro.shoppingmall.controller.orders;


import com.elepro.shoppingmall.entity.orders.ShoppingCart;
import com.elepro.shoppingmall.service.orders.ApiShoppingCartServiceIm;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/shoppingCart")
@CrossOrigin
public class ShoppingCartController {

    @Autowired
    private ApiShoppingCartServiceIm apiShoppingCartServiceIm;

    @GetMapping("/getShoppingCartList")
    public List<ShoppingCart> getShoppingCartList(@RequestParam("userId") Long userId){
        return apiShoppingCartServiceIm.getShoppingCartList(userId);
    }

    @PostMapping("/insertShoppingCart")
    public String insertShoppingCart(ShoppingCart shoppingCart){

        String result = apiShoppingCartServiceIm.insertShoppingCart(shoppingCart);
        return result;
    }

    @PostMapping("/deleteShoppingCart")
    public String deleteShoppingCart(ShoppingCart shoppingCart){
        String result = apiShoppingCartServiceIm.deleteShoppingCart(shoppingCart);
        return result;
    }
}
